package com.example.widget

import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.widget.custom.CustomActivity
import com.example.widget.databinding.ActivityMainBinding
import com.example.widget.recycler.RecyclerActivity
import com.example.widget.util.launchActivity

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        binding = ActivityMainBinding.inflate(layoutInflater)
        val view = binding.root
        setContentView(view)
        ViewCompat.setOnApplyWindowInsetsListener(view){ v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        initButtons()

        launchActivity<WebViewActivity>()
    }

    private fun initButtons() {
        binding.customView.setOnClickListener {
            launchActivity<CustomActivity>()
        }
        binding.recyclerViewBtn.setOnClickListener {
            launchActivity<RecyclerActivity>()
        }
        binding.webViewBtn.setOnClickListener {
            launchActivity<WebViewActivity>()
        }
    }
}